﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using ActionSystem.Core.Ranges;
using ActionSystem.Core.Utils;

namespace ActionSystem.Core.ComboLogic
{
    public abstract class RangeBoxItem2D : BaseRangeBoxItem
    {
        const int HIT_RESULT_MAX_COUNT = 20;
        protected Collider2D[] hitColiderRes = new Collider2D[HIT_RESULT_MAX_COUNT];
        protected RangeBoxItem2D[] hitRes = new RangeBoxItem2D[HIT_RESULT_MAX_COUNT];
        protected Collider2D hitBox=null;

        public static new RangeBoxItem2D GetRangeBoxItem<T>() where T: RangeBoxItem2D
        {
            return GameObjectPool<T>.Create();
        }       

        public override void PoolItemReset()
        {
            if(hitBox==null)
            {
                hitBox = InitCollider();
                hitBox.isTrigger = true;
            }            
        }

        /// <summary>
        /// 生成当前box的碰撞器
        /// </summary>
        /// <returns>碰撞器</returns>
        public abstract Collider2D InitCollider();
        public RangeBoxItem2D[] HitResult => hitRes;

    }
}

